package com.zhangye.test.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zhangye.test.mapper.ArRecommendMapper;
import com.zhangye.test.model.ArRecommend;
import com.zhangye.test.util.PageInfo;

@Service
public class ArRecommendService {

	@Autowired
	private ArRecommendMapper arRecommendMapper;
	
	
	public int insert(ArRecommend ar){
		int i = arRecommendMapper.insert(ar);
		return i;
	}
	

	public List<Map<String,Object>> selectByPage(PageInfo pageInfo, String where, String order) {
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("myCount", pageInfo.getCount());
		param.put("pageSize", pageInfo.getPageSize());
		param.put("page", pageInfo.getPage());
		param.put("where", where);
		param.put("order", order);
		List<Map<String, Object>> m = arRecommendMapper.selectByPage(param);
		pageInfo.setCount(Integer.parseInt(param.get("myCount").toString()));
		return m;
	}
	
	
	public int deleted(Long id){
		int i = arRecommendMapper.deleteByPrimaryKey(id);
		return i;
	}
	
	
	public List<ArRecommend> selectByWhere(String where){
		List<ArRecommend> list = arRecommendMapper.selectByWhere(where);
		return list;
	}
}
